import request from '@/utils/request'

export default {




  save(article){
    return request({
      url: '/article/save',
      method: 'post',
      data:{
        title: article.title,
        content:article.content,
        category:article.category
      }
    });
  },
  getById(articleId){
    return request({
      url: '/article/getById',
      method: 'get',
      params: {
        articleId: articleId
      }
    });
  },
  list(keyword){
    return request({
      url: '/article/list',
      method: 'get',
      params: {
        keyword: keyword
      }
    });
  },
  listById(){
    return request({
      url: '/article/listById',
      method: 'get'
    });
  },
  queryPerson(){
    return request({
      url: '/user/person',
      method: 'get'
    });
  },
  like(articleId,state){
    return request({
      url: '/article/like',
      method: 'get',
      params: {
        articleId: articleId,
        state:state
      }
    });
  },
  store(articleId,state){
    return request({
      url: '/article/store',
      method: 'get',
      params: {
        articleId: articleId,
        state:state
      }
    });
  },
  getStoreList(){
    return request({
      url: '/article/storeList',
      method: 'get',
    });
  },
  updateById(article){//修改文章
    return request({
      url: '/article/updateById',
      method: 'post',
      data:{
        id: article.id,
        title: article.title,
        content:article.content,
        category:article.category
      }
    });
  },
  pushComment(comment){//新增评论
    return request({
      url: '/article/pushComment',
      method: 'post',
      data:{
        articleId: comment.articleId,
        parentId: comment.parentId,
        content: comment.content,
        replyCommentId:comment.replyCommentId
    }
    });
  },
  commentList(articleId){//获取评论列表
    return request({
      url: '/article/commentList',
      method: 'get',
      params: {
        articleId: articleId
      }
    });
  },
  likeComment(commentId,state){//点赞评论
    return request({
      url: '/article/likeComment',
      method: 'get',
      params: {
        commentId: commentId,
        state:state
      }
    });
  },
  // commentList(articleId){//获取评论列表
  //   return request({
  //     url: '/article/commentList',
  //     method: 'get',
  //     params: {
  //       articleId: articleId
  //     }
  //   });
  // },
  // ====================================
  getUserList(searchModel) {
    return request({
      url: '/user/list',
      method: 'get',
      params: {
        pageNow: searchModel.pageNow,
        pageSize: searchModel.pageSize,
        username: searchModel.condition,

      }
    });
  },
  deleteUser(user) {
    return request({
      url: '/user',
      method: 'delete',
      params: {
        "id":user.id
      }
    });
  },
  getUserRole(username){
    return request({
      url: '/user/getUserRoles',
      method: 'get',
      params: {
        "username":username
      }
    });
  },

  getCode(number){
    return request({
      url: '/user/code?'+number,
      method: 'get',
      
    });
  },
  updateUser(editUser){
    return request({
      url: '/user/update',
      method: 'post',
      data:{
        id:editUser.id,
        username:editUser.username,
        userNick:editUser.userNick,
        email:editUser.email,
        phone:editUser.phone,
        address:editUser.address,
      }
    });
  },
  updateUserRole(id,roleIdList){
    return request({
      url: '/user/upUserRole',
      method: 'post',
      data:{
        id:id,
        roleIdList:roleIdList
      }
    });
  },

  removeBatch(val){
    return request({
      url: '/user/batch',
      method: 'post',
      data: val
    });
  },
  

} 